package com.cskaoyan.controller.backgroundsystemcontroller;


import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.ConfigMallServiceImpl;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 回显及更新商场 运费 订单 微信的配置
 *
 * @author: ckd
 * @class: MallConfigController
 * @creater: 程凯迪
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("admin/config")
public class MallConfigController {
    @Autowired
    ConfigMallServiceImpl configMallServiceImpl;

    @GetMapping("mall")
    @RequiresPermissions(value = {"*","admin:config:mall:list"},logical = Logical.OR)
    public BaseRespVo configMall() {
        ConfigMallVO configMallVO = configMallServiceImpl.configMall();
        return BaseRespVo.ok(configMallVO, "成功");
    }
    @RequiresPermissions(value = {"*","admin:config:mall:updateConfigs"},logical = Logical.OR)
    @PostMapping("mall")
    public BaseRespVo updateConfigMall(@RequestBody ConfigMallVO configMallbo) {
        configMallServiceImpl.updateConfigMall(configMallbo);
        return BaseRespVo.ok();
    }
    @RequiresPermissions(value = {"*","admin:config:express:list"},logical = Logical.OR)
    @GetMapping("express")
    public BaseRespVo configExpress() {
        ConfigExpressVO configExpressVO = configMallServiceImpl.configExpress();
        return BaseRespVo.ok(configExpressVO, "成功");
    }

    @PostMapping("express")
    @RequiresPermissions(value = {"*","admin:config:express:list"},logical = Logical.OR)
    public BaseRespVo updateConfigExpress(@RequestBody ConfigExpressVO configExpressVO) {
        //java.lang.System.out.println(configExpressVO);
        configMallServiceImpl.updateConfigExpress(configExpressVO);
        return BaseRespVo.ok();
    }

    @GetMapping("order")
    @RequiresPermissions(value = {"*","admin:config:order:updateConfigs"},logical = Logical.OR)
    public BaseRespVo configOrder() {
        ConfigOrderVO configOrderVO = configMallServiceImpl.configOrder();
        return BaseRespVo.ok(configOrderVO, "成功");
    }

    @PostMapping("order")
    @RequiresPermissions(value = {"*","admin:config:order:updateConfigs"},logical = Logical.OR)
    public BaseRespVo updateConfigOrder(@RequestBody ConfigOrderVO configOrderVO) {
        configMallServiceImpl.updateConfigOrder(configOrderVO);
        return BaseRespVo.ok();
    }
    @RequiresPermissions(value = {"*","admin:config:wx:list"},logical = Logical.OR)
    @GetMapping("wx")
    public BaseRespVo configWx() {
        ConfigWxVO configWxVO = configMallServiceImpl.configWx();
        //java.lang.System.out.println(configWxVO);
        return BaseRespVo.ok(configWxVO, "成功");
    }

    @PostMapping("wx")
    @RequiresPermissions(value = {"*","admin:config:wx:updateConfigs"},logical = Logical.OR)
    public BaseRespVo updateConfigWx(@RequestBody ConfigWxVO configWxVO) {
        //java.lang.System.out.println(configWxVO);
        configMallServiceImpl.updateConfigWx(configWxVO);
        return BaseRespVo.ok();
    }
}
